function MyBitmap(size) {
    this.words = new Array(this._getWordIndex(size - 1) + 1);
    this.size = size;
}

MyBitmap.prototype._getWordIndex = function(bitIndex) {
    return bitIndex >>> 5;
};

MyBitmap.prototype.getBit = function(bitIndex) {
    if(bitIndex < 0 || bitIndex > this.size - 1){
        throw new Error("超过bitmap有效范围");
    }
    var wordIndex = this._getWordIndex(bitIndex);
    return (this.words[wordIndex] & (1 << bitIndex)) != 0;
};

MyBitmap.prototype.setBit = function(bitIndex) {
    if(bitIndex < 0 || bitIndex > this.size - 1){
        throw new Error("超过bitmap有效范围");
    }
    var wordIndex = this._getWordIndex(bitIndex);
    this.words[wordIndex] |= (1 << bitIndex);
};

var bitMap = new MyBitmap(128);
bitMap.setBit(126);
bitMap.setBit(75);
console.log(bitMap.getBit(126));
console.log(bitMap.getBit(78));